import React from 'react'
import css from './Article.module.less'
import coverImg from '@/assets/images/meta.jpg'
import { IFArticle } from '@/store/reducer'
import { baseURL } from '@/config'

type P = {
  item: IFArticle
  handel: (e: IFArticle) => void
}

type S = {}

export default class Article extends React.Component<P, S> {
  constructor(props: P) {
    super(props)
    this.state = {}
  }
  render() {
    const { fileName, cover } = this.props.item
    return (
      <div
        className={css.card}
        onClick={() => this.props.handel(this.props.item)}
      >
        <div>
          <div
            className={css.cover}
            style={{
              backgroundImage: `url(${cover ? baseURL + cover : coverImg})`
            }}
          ></div>
        </div>
        <div className={css.meta_box}>
          <h2>
            <div>{fileName}</div>
          </h2>
        </div>
      </div>
    )
  }
}
